home *** CD-ROM | disk | FTP | other *** search
Text File | 1988-08-07 | 2.2 KB | 72 lines | [TEXT/TRUE] |
- !Color Picker Demo
- !Demonstrates True Basic's True Windows and
- !illustrates use of the Color Picker routine
- !©1988 MacTutor
- !By Dave Kelly
-
- LIBRARY "TrueWindows*","QuickLib*","PickerLib*"
- LIBRARY "datalib*", "maclib*", "system*"
-
- DECLARE DEF H,V,GetColor$,UnpackEnvirons$,RGB$
- DIM menu$(0:1,0:2)
- LET false=0
- LET true=1
- LET Done=false
- CALL tw_init("COLOR") ! Color isn't supported yet, but I'm ready for it!
- ! Find out what kind of computer this is
- CALL SysEnvirons(sysEnvRec$,status)
- CALL UnpackEnvirons(sysEnvRec$,envversion,machine,sysversion, processor, hasFPU,hasColorQD,keyboardtype,atversion, sysvrefnum)
- IF hasColorQD<>1 then
- ! we gotta quit, this isn't a Mac II
- LET done=true
- CALL tw_dwarn(3,"Color Quickdraw is not available! Sorry, but you can't run this !","OK",1,result)
- END IF
- IF done<> true then
- MAT READ menu$
- DATA "",About MacTutor Picker Demo...,""
- DATA File,Get Picker...,Quit
- CALL tw_menu_set(menu$) ! Set up the menu
-
- DO
- CALL tw_event(maxnum,type$,window,menunumber,menuitem)
- SELECT CASE type$
- CASE "MENU"
- SELECT CASE menunumber
- CASE 0
- CALL About
- CASE 1
- CALL file(menuitem,done,inrgb$)
- CASE ELSE
- END SELECT
- CASE ELSE
- END SELECT
- LOOP Until Done=true
- CALL tw_menu_clear ! Get rid of the menus
- END IF
- CALL tw_cleanup ! clean up all the TrueWindows stuff
- END
-
- SUB about
- ! Set up the About dialog box.
- CALL tw_dwarn(0,"MacTutor Picker Demo|©1988 MacTutor|By Dave Kelly","OK",1,Result)
- END SUB
-
- SUB file(menuitem,done,inrgb$)
- SELECT CASE menuitem
- CASE 1
- ! Set up the upper corner of picker dialog
- CALL SetPt(Point$,0,0)
- ! do picker dialog
- CALL GetColor(point$,"Pick a color, just for fun!",inrgb$,outrgb$,okflag)
- ! select the color
- IF okflag=1 then LET inrgb$=outrgb$
- CALL unpackRGB(inrgb$,r,g,b)
- LET string$="Color selected was:|r="&str$(r)&"|g="&str$(g)&"|b="&str$(b)
- ! Display the color in rgb coordinates
- CALL tw_dwarn(1,string$,"OK",1,result)
- CASE 2
- LET done=1
- CASE ELSE
- END SELECT
- END SUB
-